package com.traffic.controller;

import com.traffic.model.ApiResponse;
import com.traffic.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "短信相关接口")
@RestController
@RequestMapping(value = "/sms")
@Slf4j
public class SmsController {
    @Autowired
    SmsService smsService;

    @ApiOperation(value = "【短信接口-发送短信验证码】", notes = "获取短信验证码")
    @GetMapping("/send/{phone}")
    public ApiResponse sms(@PathVariable String phone) {
        return smsService.sendSms(phone);
    }

    @ApiOperation(value = "【短信接口-进行验证码验证】", notes = "获取短信验证码")
    @GetMapping("/check/{phone}/{code}")
    public ApiResponse check(@PathVariable String phone, @PathVariable String code){
        return smsService.check(phone, code);
    }
}
